package com.pe1n.yangtaopai.presenter;

import com.pe1n.yangtaopai.bean.IntemOneListBean;
import com.pe1n.yangtaopai.modle.ModeIntemOne;
import com.pe1n.yangtaopai.view.interfacese.IViewIntemOne;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2016/11/25.
 */

public class PresenterIntemOne implements IPresenterIntemOne {
    private ModeIntemOne modeIntemOne;
    private IViewIntemOne iViewIntemOne;
    public PresenterIntemOne(IViewIntemOne iViewIntemOne){
        this.modeIntemOne=new ModeIntemOne();
        this.iViewIntemOne=iViewIntemOne;
    }

    @Override
    public void LoadItemListOneData(String urlString) {
        modeIntemOne.getIntemOneListBean(urlString)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<IntemOneListBean>() {
                    @Override
                    public void onCompleted() {
                        iViewIntemOne.showProgress();
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(IntemOneListBean intemOneListBean) {
                        iViewIntemOne.LoadItemListOneData(intemOneListBean);
                    }
                });

    }


}
